package com.gxa.domain.dto;

import com.gxa.domain.entity.Product;
import lombok.Data;

import java.math.BigDecimal;

@Data
public class ProductDTO {
    private Integer serialNo;
    private String barcodeNo;
    private String productName;
    private BigDecimal sellingPrice;
    private String unit;
    private Integer stockQuantity;
    private Product.ProductStatus status;
    private String operatorName;  // 前端传递的操作人姓名
    private Integer operatorId;   // 后端查询到的操作人ID
    private String firstCategoryName;
    private Integer firstLevelCategory;
    private String secondCategoryName;
    private Integer secondLevelCategory;
    
    // 转换为Product实体
    public Product toProduct() {
        Product product = new Product();
        product.setSerialNo(this.serialNo);
        product.setBarcodeNo(this.barcodeNo);
        product.setProductName(this.productName);
        product.setSellingPrice(this.sellingPrice);
        product.setUnit(this.unit);
        product.setStockQuantity(this.stockQuantity);
        product.setStatus(this.status);
        product.setOperatorId(this.operatorId);
        product.setFirstLevelCategory(this.firstLevelCategory);
        product.setSecondLevelCategory(this.secondLevelCategory);
        return product;
    }
} 